<template>
    <section class="newsletter">
        <div class="container">
            <h3>{{ title }}</h3>
            <p>{{ subtitle }}</p>
            <form @submit.prevent="$emit('subscribe', email)">
                <input type="email" v-model="email" :placeholder="placeholder" required>
                <button type="submit">{{ buttonText }}</button>
            </form>
        </div>
    </section>
</template>

<script>
export default {
    name: 'NewsletterSubscription',
    props: {
        title: {
            type: String,
            default: '订阅获取独家旅行优惠'
        },
        subtitle: {
            type: String,
            default: '第一时间获取限时折扣和旅行灵感'
        },
        placeholder: {
            type: String,
            default: '您的电子邮箱'
        },
        buttonText: {
            type: String,
            default: '订阅'
        }
    },
    data() {
        return {
            email: ''
        }
    }
}
</script>

<style scoped>
.newsletter {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 60px 0;
    text-align: center;
}

.newsletter h3 {
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.newsletter p {
    margin-bottom: 25px;
    opacity: 0.9;
}

.newsletter form {
    display: flex;
    max-width: 500px;
    margin: 0 auto;
}

.newsletter input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 50px 0 0 50px;
    font-size: 1rem;
}

.newsletter button {
    padding: 12px 25px;
    background: var(--dark-color);
    color: var(--white);
    border: none;
    border-radius: 0 50px 50px 0;
    cursor: pointer;
    transition: var(--transition);
}

.newsletter button:hover {
    background: #1e272e;
}

@media (max-width: 768px) {
    .newsletter form {
        flex-direction: column;
    }

    .newsletter input,
    .newsletter button {
        border-radius: 50px;
    }

    .newsletter button {
        margin-top: 10px;
    }
}
</style>